package controller;

import pojo.User;
import service.UserService;
import view.UserDetails;
import view.UserView;

import javax.swing.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

public class UserClickListener implements MouseListener {
    private JTable table;
    private UserView userView;
    public UserClickListener(UserView dialog){
        this.userView=dialog;
    }

    @Override
    public void mouseClicked(MouseEvent e) {
        int selRow = table.getSelectedRow();
        String userId = table.getValueAt(selRow,0).toString().trim();
        UserService userService = new UserService();
        User user =  userService.search(userId);
        UserDetails userDetails = new UserDetails(user,userView);
    }

    @Override
    public void mousePressed(MouseEvent e) {

    }

    @Override
    public void mouseReleased(MouseEvent e) {

    }

    @Override
    public void mouseEntered(MouseEvent e) {

    }

    @Override
    public void mouseExited(MouseEvent e) {

    }

    public void setTable(JTable table) {
        this.table=table;
    }
}
